package functions;

import main.ContingencyTable;

public class JMeasureFunction extends GeneralFunction {

	public JMeasureFunction(String name) {
		super(name);
	}

	@Override
	public double calculate(ContingencyTable t) {
		return (t.f11() / t.N())
				* log2((t.N() * t.f11()) / (t.f1p() * t.fp1()))
				+ (t.f10() / t.N())
				* log2((t.N() * t.f10()) / (t.f1p() * t.fp0()));
	}

	double log2(double a) {
		return Math.log(a) / Math.log(2);
	}
}
